<?php
    /**
     * User: Viet Anh
     * Date: 10/06/2014
     * Time: 23:31
     */

    require_once dirname(dirname(__FILE__)) . '/config/config.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_CONFIG . 'connection.php';

    class dao_option
    {

        public function __construct()
        {

        }

        public function get_option_value($name)
        {
            $db  = new connection();
            $con = $db->open_connect();

            $query = "SELECT * FROM tbl_option WHERE name = '$name'";
            $result = mysqli_query($con, $query)
            or die("Query fail: " . mysqli_error());
            $row = mysqli_fetch_array($result);
            $db->close_connect();

            return $row['value'];
        }

        public function set_option_value($name, $value)
        {
            $db  = new connection();
            $con = $db->open_connect();

            $query = "UPDATE tbl_option SET value = '$value' WHERE name = '$name'";
            $result = mysqli_query($con, $query)
            or die("Query fail: " . mysqli_error());
            $db->close_connect();

            return TRUE;
        }
    }